package com.seu.magicfilter.camera.utils

import android.hardware.Camera


object CameraUtils {
    @JvmStatic
    fun getLargePictureSize(camera: Camera?): Camera.Size? {
        if (camera != null) {
            val sizes = camera.parameters.supportedPictureSizes
            var temp = sizes[0]
            for (i in 1 until sizes.size) {
                val scale = sizes[i].height.toFloat() / sizes[i].width
                if (temp.width < sizes[i].width && scale < 0.6f && scale > 0.5f) temp = sizes[i]
            }
            return temp
        }
        return null
    }

    @JvmStatic
    fun getLargePreviewSize(camera: Camera?): Camera.Size? {
        camera?.apply {
            val sizes = camera.parameters.supportedPreviewSizes
            var temp = sizes[0]
            for (i in 1 until sizes.size) {
                if (temp.height < sizes[i].height) temp = sizes[i]
            }
            return temp
        }

        return null
    }
}